package com.holy.sh.module_base_mvp.utils;

import android.app.Application;
import android.content.Context;
import android.widget.Toast;


/**
 * Created by yili on 2019/1/7.
 * Email : victorhhl@163.com
 * Description : 提示的工具类
 */
public class ToastUtil {

    public static boolean isShow = true;

    private static Application instanceContext;

    private static Toast toast = null;

    public static void initialize(Application context) {
        instanceContext = context;
    }

    public static void show(Context context, String content) {
        checkNotNull();
        show(content);
    }

    public static void show(Context context, int content) {
        checkNotNull();
        show(content);
    }

    public static void show(String content) {
        checkNotNull();
        if (toast == null) {
            toast = Toast.makeText(instanceContext, content, Toast.LENGTH_SHORT);
        } else {
            toast.setText(content);
        }
        toast.show();
    }

    public static void show(int content) {
        checkNotNull();
        if (toast == null) {
            toast = Toast.makeText(instanceContext, content, Toast.LENGTH_SHORT);
        } else {
            toast.setText(content);
        }
        toast.show();
    }

    private static void checkNotNull() {
        NullUtils.chekcNoNull(instanceContext);
    }

   /* public static void showCus(Context context, String content, @LayoutRes int layout) {
        if (null != context && isShow) {
            View contentView = LayoutInflater.from(context).inflate(layout, null);
            ((TextView) contentView.findViewById(R.id.tv_msg)).setText(content);
            Toast toast = new Toast(context);
            toast.setView(contentView);
            toast.show();
        }
    }*/

    public static void showSuccess(){
        ToastUtil.show("删除成功！");
    }

    public static void showFlial(){
        ToastUtil.show("删除失败！");
    }
}